package com.example.chartroom1.controller;

import com.example.chartroom1.mapper.MessageMapper;
import com.example.chartroom1.model.Message;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageController {
    @Resource
    private MessageMapper messageMapper;

    @RequestMapping("/getMessage")
    public Object getMessage(int sessionId) {
        List<Message> messages = messageMapper.getMessageBySession(sessionId);
        Collections.reverse(messages);
        return messages;
    }
}
